package com.Ryan.B_Controller;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import javax.sql.DataSource;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.Ryan.A_Bean.User;
import com.Ryan.C_Service.UserServiceInte;

@RestController
public class DataSourceController {
	@Autowired
	private UserServiceInte userServiceInte;
	// 没有指定为主数据源.
	@Autowired
	private DataSource dataSource;

	@Autowired
	@Qualifier("ds1")
	private DataSource dataSource1;

	@Autowired
	@Qualifier("ds2")
	private DataSource dataSource2;

	@Autowired
	@Qualifier("ds3")
	private DataSource dataSource3;

	@RequestMapping("ds1")
	public Integer ds1() throws Exception {
		SqlSessionFactoryBean bean = new SqlSessionFactoryBean();
		bean.setDataSource(dataSource1);
		return userServiceInte.save_user(new User());
	}

}
